Video compression algorithms typically represent visual information by a combination of motion data and texture data. The motion data describes the temporal relationship between the content of a frame and that of a previous frame. Motion data is typically represented by a set of motion vectors associated with blocks that define a partition of a frame. For each block, a motion vector describes the horizontal and vertical displacement with respect to a previous frame. The correlation between motion vectors belonging to adjacent blocks is typically high, and therefore differential coding methods are typically employed to code motion vectors.
Motion vectors are differentially coded with respect to a single prediction. This single prediction may be obtained by combining several motion vectors, for example by using a median operator (see ISO/IEC 14496-2 (1999) and ISO/IEC 14496-10 (2003)). Alternatively, the prediction may be obtained by referring to a single motion vector (see ISO/IEC 13818-2).
Related art solutions can be inefficient in some cases, where efficiency is defined by the number of bits required to code a set of motion vectors. For example, when a median operator is used as in ISO/IEC 14496-2 in the presence of a horizontal motion boundary, a same non-zero difference will be encoded multiple times even though a zero difference could be encoded with respect to a locally available motion vector (e.g., the motion vector to the left).
Consider two rows of motion vectors. The motion vectors in the top row all have value A and the ones in the bottom row value B:                AAAAAAAA        BBBBBBBBWhen encoding the bottom row of motion vectors, the prediction generated by the median operator will always have value A. Therefore, the difference between the values A and B will be encoded multiple times. It is preferable to have a coding method that encodes mostly zero value differences for the bottom row.        
The prediction method in ISO/IEC 13818-2 works well with the pattern described above in that it generates zero differences. However, the prediction is inefficient in the presence of a vertical motion field boundary, as the prediction always refers to the block to the left. An example of a vertical motion boundary is described below:                AB        AB        AB        AB        
A motion vector prediction and coding method is thus sought that efficiently encodes motion vectors in the presence of either or both horizontal and vertical motion boundaries.